// 封装获取频道列表的逻辑
import { useEffect, useState } from 'react'
import { getChannelAPI } from '@/apis/article'
function useChannel() {
    // 1.获取频道列表数据
    const [channelList, setChannelList] = useState([])

    useEffect(() => {
        const getChannelList = async () => {
            const { data: { channels } } = await getChannelAPI()
            setChannelList(channels)
        }
        getChannelList()
    }, [])

    // 2.把组件中要使用的数据return出去
    return {
        channelList
    }
}
export { useChannel }